<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<form id="addForm">
    <input type="text" name="goodsId" id="goodsId" th:value="${goodsId}">
    <div class="form-group">
        <label for="comment">评论内容</label>
        <input type="text" name="comment" class="form-control" id="comment" placeholder="评论内容">
    </div>
    <button type="button" onclick="saveComment()" class="btn btn-default">提交</button>
</form>
</body>
</html>
<script>
    function saveComment() {
        $.ajax({
            url : "/comment/saveComment",
            dataType:"json",
            data : {
                goodsId:$("#goodsId").val(),
                comment:$("#comment").val()
            },
            type : "post",
            success : function (data) {
                if (data.code == 200) {
                    alert("添加成功")
                } else {
                    alert("添加失败")
                }
            }
        })
    }
</script>